package com.student.Activitys.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.student.Activitys.R;

/**
 * 项目名称：智慧校园学生端
 * 类描述：首页签到 dialog
 * 创建人：张飞祥
 * 创建时间：2017/9/27 16:17
 * 修改人：张飞祥
 * 修改时间：2017/9/27 16:17
 * 修改备注：
 */
public abstract class HomeSignDialog extends Dialog implements View.OnClickListener {

    //退出按钮
    ImageView ivSignExit;
    //时间
    TextView tvSignDate;
    //内容
    TextView tvSignContent;
    //签到
    Button btnSign;

    private Activity activity;

    public HomeSignDialog(@NonNull Activity activity) {
        super(activity, R.style.HomeStageDialogTheme);
        this.activity = activity;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //初始化加载
        setContentView(R.layout.dialog_home_sign);
        ivSignExit = (ImageView) findViewById(R.id.iv_sign_exit);
        tvSignDate = (TextView) findViewById(R.id.tv_sign_date);
        tvSignContent = (TextView) findViewById(R.id.tv_sign_content);
        btnSign = (Button) findViewById(R.id.btn_sign);
        //给予外部控件调用
        setView(tvSignDate, tvSignContent,btnSign);
        //点击事件监听
        ivSignExit.setOnClickListener(this);
        btnSign.setOnClickListener(this);
    }

    /**
     * 点击事件
     * @param v
     */
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_sign_exit:         //退出
                this.cancel();
                break;
            case R.id.btn_sign:             //签到
                setSign();
                this.cancel();
                break;
        }
    }

    //外部控件调用方法
    public abstract void setView(TextView tvSignDate, TextView tvSignContent,Button btnSign);
    public abstract void setSign();
}
